package com.grwx.omc.baselog.controller;

import com.grwx.omc.baselog.service.IOperationLogService;
import com.grwx.omc.common.entity.LoginLog;
import com.grwx.omc.common.entity.OperationLog;
import com.grwx.omc.common.entity.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Description: 用户操作日志的记录
 * @Author: ManJiang
 * @Date: 2020/5/11
 */
@RestController
@RequestMapping("/log")
public class OperationLogController {
    @Autowired
    private IOperationLogService operationLogService;

    /**
     * 操作日志的添加
     * @param operationLog
     * @return
     */
    @RequestMapping("/operation_add")
    public int addoperationLog(@RequestBody OperationLog operationLog){
        return operationLogService.addOperationLog(operationLog);
    }

    /**
     * 操作日志的分页查询
     * @param map 分页参数.
     * @return
     */
    @RequestMapping("/operation_pagelist")
    public PageData<OperationLog> getLoginLogs(@RequestBody Map<String,Integer> map){
        Integer totalCount = operationLogService.getTotalCount();

        List<OperationLog> operationLogs = operationLogService.getOperationLogs(map);

        PageData<OperationLog> pageData = new PageData<OperationLog>(map.get("pageIndex"),map.get("pageSize"),totalCount,operationLogs);

        return pageData;
    }
}
